﻿#include<stdio.h>
void print(char pos1, char pos2)
{
	printf(" %c->%c ", pos1, pos2);
}
void Hanio(int n, char star, char temp, char end)
{
	if (n == 1)
	{
		print(star, end);
	}
	else
	{
		Hanio(n - 1, star, end, temp);
		print(star, end);
		Hanio(n - 1, temp, star, end);
	}
}
int main()
{
	int n = 0;
	printf("请输入塔的层数：\n");
	scanf_s("%d", &n);
	char pos1 = 'A';
	char pos2 = 'B';
	char pos3 = 'C';
	Hanio(n, pos1, pos2, pos3);
	return 0;
}